import { Axios } from '@/axios/axiosPlugin'
import { baseURL } from '@/config'
import axios from 'axios'

export const getAllUsers = () => {
    return Axios({
        url: '/user/all',
        method: 'get'
    })
}
export const getUser = (id) => {
    return Axios({
        url: '/user/'+id,
        method: 'get',
        data:id,
    })
}
export const getAllOrders = (id) => {
    return Axios({
        url: '/order/all',
        method: 'get',
        data:id,
    })
}
export const deleteOrder = (id) => {
    return Axios({
        url: '/order/'+id,
        method: 'delete'
    })
}

export const getOrdersByStatus = (status) => {
    return Axios({
        url: '/order/status/'+status,
        method: 'get',
        data:status,
    })
}

export const changeOrdersStatus = (id) => {
    return Axios({
        url: '/order/'+id,
        method: 'post',
    })
}
export const changeOrdersAddress = (id,param) => {
    return Axios({
        url: '/order/'+id,
        method: 'put',
        data:param,
    })
}
export const searchOrder = (id) => {
    return Axios({
        url: '/order/'+id,
        method: 'get',
        data:id,
    })
}

export const login = (param) => {
    return axios({
        url: baseURL + '/login',
        method: 'post',
        data:param,
    })
}

export const editUser = (param) => {
    return Axios({
        url: '/user/password',
        method: 'put',
        data:param,
    })
}
export const deleteUser = (id) => {
    return Axios({
        url: '/user/'+id,
        method: 'delete',
        data:id,
    })
}
export const cancelUser = (id) => {
    return Axios({
        url: '/user/'+id,
        method: 'put',
    })
}



export const addArticle = (param) => {
    return Axios({
        url: '/essay',
        method: 'post',
        data:param,
    })
}
export const deleteArticle = (id) => {
    return Axios({
        url: '/essay/'+id,
        method: 'delete',
        data:id,
    })
}

export const getAllArticles = () => {
    return Axios({
        url: '/essay/all',
        method: 'get',

    })
}

export const getArticleByTime = (sort) => {
    return Axios({
        url: '/essay/all/'+sort,
        method: 'get',
        data:sort,
    })
}

export const updateArticle = (id) => {
    return Axios({
        url: '/essay/'+id,
        method: 'post',

    })
}
export const getAllItems = () => {
    return Axios({
        url: '/goods/all',
        method: 'get',

    })
}
export const getItemByName = (name) => {
    return Axios({
        url: '/goods/'+name,
        method: 'get',
        data:name,
    })
}
export const changeItemNum = (param) => {
    return Axios({
        url: '/goods/number',
        method: 'put',
        data:param,

    })
}
export const changeItem = (param) => {
    return Axios({
        url: '/goods/change',
        method: 'put',
        data:param,

    })
}
export const addItem = (param) => {
    return Axios({
        url: '/goods/add',
        method: 'post',
        data:param,
    })
}
export const deleteItem = (id) => {
    return Axios({
        url: '/goods/'+id,
        method: 'delete',
        data:id,

    })
}

export const getAllMap = () => {
    return Axios({
        url: '/map/all',
        method: 'get',


    })
}

export const getMarkByStatus = (status) => {
    return Axios({
        url: '/map/status/'+status,
        method: 'get',
        data:status


    })
}

export const changeMarkStatus = (id,status) => {
    return Axios({
        url: '/map/'+id,
        method: 'put',
        data:status

    })
}
export const addMark = (param) => {
    return Axios({
        url: '/map/add',
        method: 'post',
        data:param


    })
}

export const getAllData = () => {
    return Axios({
        url: '/trash/all',
        method: 'get',


    })
}

export const getDataByStatus = (status) => {
    return Axios({
        url: '/trash/'+status,
        method: 'get',
        data:status


    })
}